package com.fangcun.controller.sys;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fangcun.bean.sys.ResponseMsg;
import com.fangcun.common.TestRequestAsync;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.util.PublicMethod;

/**
 * @作者： 陳曉鬆 @时间： 2020年4月28日 - 上午10:34:54 @description：-> 七牛云
 */
@RestController
@RequestMapping("/test/")
public class TestController {

	private static Logger LOG = LoggerFactory.getLogger(TestController.class);

	@Autowired
	private TestRequestAsync testRequestAsync;

	@RequestMapping("test1")
	public ResponseMsg uploadChatImage(int number) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			for (int i = 1; i <= number; i++) {
				testRequestAsync.test(i);
			}
		} catch (Exception e) {
			LOG.error("-压力测试异常->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}

}
